package com.projectzqjz.parttimework.adapter;


import android.app.Activity;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.projectzqjz.parttimework.R;
import com.projectzqjz.parttimework.entity.ScreenEntity;
import com.projectzqjz.parttimework.utils.ScreenUtil;

import java.util.List;

public class PartSearchAdapter extends BaseQuickAdapter<ScreenEntity, BaseViewHolder> {
    private Activity activity;
    private int screenWidth;
    private int intervalWidth;


    public PartSearchAdapter(Activity activity, List<ScreenEntity> list) {
        super(R.layout.item_screen, list);
        this.activity = activity;
        screenWidth = ScreenUtil.getScreenWidth(activity);
        intervalWidth = ScreenUtil.dip2px(activity, 47);
    }

    @Override
    protected void convert(BaseViewHolder helper, ScreenEntity item) {
        TextView ll_gg = helper.getView(R.id.tv_);

        LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) ll_gg.getLayoutParams(); //取控件textView当前的布局参数 linearParams.height = 20;// 控件的高强制设成20

        linearParams.width = (screenWidth - intervalWidth) / 4;// 控件的宽强制设成30

        ll_gg.setLayoutParams(linearParams);
        ll_gg.setText(item.getDetail());

    }

}
